// tableColumns.ts
import { computed } from 'vue'
import type { TableColumnType } from 'ant-design-vue'
import type { Role } from '@/types/api/system/role'

/**
 * 获取角色管理表格列配置
 * @returns 表格列配置数组
 */
export const useTableColumns = () => {
  const { t } = useI18n()
  
  const columns = computed<TableColumnType<Role>[]>(() => [
    {
      title: t('role.name'),
      dataIndex: 'roleName',
      key: 'roleName'
    },
    {
      title: t('role.code'),
      dataIndex: 'roleCode',
      key: 'roleCode'
    },
    {
      title: t('role.sort'),
      dataIndex: 'roleSort',
      key: 'roleSort',
      width: 80
    },
    {
      title: t('role.status'),
      dataIndex: 'status',
      key: 'status',
      width: 100,
      customRender: ({ text }) => {
        return text === 1 ? t('common.enabled') : t('common.disabled')
      }
    },
    {
      title: t('common.createTime'),
      dataIndex: 'createTime',
      key: 'createTime',
      width: 180
    },
    {
      title: t('common.action'),
      key: 'action',
      width: 200,
      fixed: 'right'
    }
  ])

  return {
    columns
  }
} 